fix(fleetcontrol): improve error handling and enforce exact value matching#1827
Open
pranav-new-relic wants to merge 2 commits intomainfrom
Open
fix(fleetcontrol): improve error handling and enforce exact value matching#1827pranav-new-relic wants to merge 2 commits intomainfrom
pranav-new-relic wants to merge 2 commits intomainfrom
Conversation
…ching - Modified GetOrganizationID() to return underlying API errors instead of generic "failed to determine organization ID" message - Removed all case-insensitive validation - values must now match exactly as specified in allowed_values lists - Removed case normalization from all Map* functions (MapManagedEntityType, MapOperatingSystemType, MapConfigurationMode, MapScopeType) - Added strict validation for agent types in ParseAgentSpec and legacy deployment syntax to ensure exact matches - Updated README to reflect case-sensitive validation requirements - Updated all GetOrganizationID() callers to properly handle error returns
- Added validation block to legacy --agent-type flag in deployment create YAML - Removed redundant code validation from fleet_deployment_create.go - Follows YAML-first validation approach: framework validates before handlers run - Code validation only remains in ParseAgentSpec for complex spec format parsing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses two issues reported by the fleet team:
Misleading error messages: When organization ID retrieval fails (e.g., due to "Unauthorized IP address"), the CLI showed a generic "failed to determine organization ID" message without revealing the underlying cause.
Inconsistent validation: The original implementation used
case_insensitive: truein YAML configs but didn't properly normalize values before sending to the API, leading to confusion about which values were actually accepted.Changes
Error Handling
GetOrganizationID()to return the actual API error, providing users with clear information about what went wrong (e.g., "Unauthorized IP address")GetOrganizationID()to properly handle the new error return valueExact Value Matching
case_insensitive: truefrom YAML config files - values must now match exactly as specifiedToUpper/ToLower) from allMap*functions to enforce exact matchingParseAgentSpec()- validates--agentflag format (e.g., "NRInfra:1.70.0:version1")fleet_deployment_create.go- validates legacy--agent-typeflagRequired Values
Users must now provide exact values as specified:
NRInfra,NRDOT,FluentBit,NRPrometheusAgent(not "nrinfra" or "NRINFRA")HOST,KUBERNETESCLUSTER(not "host" or "kubernetescluster")LINUX,WINDOWS(not "linux" or "windows")ConfigEntity,ConfigVersionEntity(not "configentity")Testing
Verified that: